ShowTable of Contents
Overview
The
Using Dynamic Variable Substitution in Composite Applications article demonstrates how variable substitution can be used during runtime to dynamically supply information to Composite Applications. This article demonstrates the extension point that allows substitution to occur.
Create the Extension
Add the org.eclipse.core.variables plugin to the dependency list. The org.eclipse.core.variables supplies the org.eclipse.core.variables.dynamicVariables extension point used to add your own variable substitution logic.
Extend and add your own substitution logic by adding the following extension.
<extension
point="org.eclipse.core.variables.dynamicVariables">
<variable
description="Resolves variables for eclipse preferences. The argument is of the format {$IBM:<pluginId>/<preferenceName>}."
name="IBM"
resolver="com.ibm.rcp.support.variables.dynamic.DynamicVariableResolver"
supportsArgument="true">
</variable>
</extension>
Create the Substitution Logic
Next, implement the logic that will perform the substitution by implementing the IDynamicVariableResolver interface. This class should be referenced in the resolver element used in the extension described previously.
public class DynamicVariableResolver implements IDynamicVariableResolver {
@Override
public String resolveValue(IDynamicVariable variable, String argument)
throws CoreException {
String[] args = argument.split("/");
// variables are of the form
// {$IBM:<pluginId>/<preferenceName>}
String plugin = args[0];
String preference = args[1];
// do some logic to substitute
if (preference.equals("ibm_url")) {
return "http://www.ibm.com";
}
return null;
}
}
Using Substitution
Similar to the
Using Dynamic Variable Substitution in Composite Applications, add a Managed Browser component to a Composite Application. Update the intialUrl component property to the value ${IBM:com.ibm.rcp.support.variable.dynamic/ibm_url}.
When the Managed Browser component initiatlizes, the substitution code will supply the
http://www.ibm.com value.